package com.snail.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.snail.common.DeleteRequest;
import com.snail.model.dto.UploadFileParamsDto;
import com.snail.model.dto.UploadFileResultDto;
import com.snail.model.pojo.BizMediaFile;
import com.snail.model.vo.VideoPageListVo;
import com.snail.response.BaseResponse;
import com.snail.response.PageResponse;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;


/**
 * @author Monica
 * @description 针对表【biz_media_file(文件储存表)】的数据库操作Service
 * @date 2025-07-16 10:22:25
 */
public interface BizMediaFileService extends IService<BizMediaFile> {

    BaseResponse<UploadFileResultDto> uploadFile(UploadFileParamsDto uploadFileParamsDto, String localFilePath);

    BizMediaFile addMediaFilesToDb(String fileMd5, UploadFileParamsDto uploadFileParamsDto, String bucketPic, String objectName);


    BaseResponse<Boolean> checkFile(String fileMd5);

    BizMediaFile getMediaFileByFileMd5(String fileMd5);

    BaseResponse<Boolean> checkChunk(String fileMd5, int chunk);

    BaseResponse uploadChunk(String fileMd5, int chunk, String localChunkFilePath);

    BaseResponse mergeChunks(String fileMd5, int chunkTotal, UploadFileParamsDto uploadFileParamsDto);

    BaseResponse<Boolean> deleteFile(String fileMd5);
    // 将视频转换为音频
    void convertVideoToAudio(File videoFile, File audioFile) throws IOException;

    /**
     * 提交音频文件进行语音识别，返回识别结果字符串
     */
    String transcribeAudioToString(File audioFile) throws IOException, ExecutionException, InterruptedException, TimeoutException;


    Path downloadVideoFile(String videoUrl) throws IOException, URISyntaxException, InterruptedException;

    PageResponse<BizMediaFile> getMediaFileList(VideoPageListVo videoPageListVo);

    BaseResponse<Boolean> deleteVideoById(DeleteRequest deleteRequest);

    BaseResponse<BizMediaFile> getMediaFileById(Integer id);
    void generateSubtitle() throws IOException;

    Integer getSubtitleId(Integer videoId);

    void updateByIdWithoutAutoFill(BizMediaFile video);
}

